package LYK;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;

public class HomepageJframe extends JFrame implements MouseListener  {
	private  JPanel top_p;//上部面板
	private  JLabel logopic;
	private  JLabel city;//选择城市
	private  JLabel homepage;//首页跳转按钮
	private  JLabel film;//影视页面跳转按钮
	private  JLabel cinema;//电影院页面调转按钮
	private  JLabel personData;
	private  JLabel out;
	//中间面板
	private JPanel center_p;
	
	private JPanel center_p_top;
	private JLabel nowFilm;
	private JLabel futureFilm;
	
	//中间滚动面板
	private  JScrollPane center_p_center;
	//中间电影图片
	private JLabel homep1;
	private JLabel homep2;
	private JLabel homep3;
	private JLabel homep4;
	private JLabel homep5;
	//购票按钮
	private JButton homeB1;
	private JButton homeB2;
	private JButton homeB3;
	private JButton homeB4;
	private JButton homeB5;
	//
	private JLabel centerpic;
	//下部的面板
	private JPanel center_p_center_bottoml;
	private JLabel filmRankingList;
	private JLabel allFilm;
	private JLabel oneFilm;
	private JLabel twoFilm;
	private JLabel threeFilm;
	private JLabel fourFilm;
	private JLabel fiveFilm;
	
	
	private JPanel center_p_center_bottomc;
	private JLabel cinemaRanking;
	private JLabel allCinema;
	private JLabel oneCinema;
	private JLabel twoCinema;
	private JLabel threeCinema;
	private JLabel fourCinema;
	private JLabel fiveCinema;
	
	private JPanel center_p_center_bottomr;
	private JLabel musicPic;
	
	
	private JPanel center_p_bottom;
	private JPanel center_p_bottoml;
	
	private JLabel newFilm;
	private JLabel test;
	
	
	
	

	
	
	
	 public HomepageJframe() {
		// TODO Auto-generated constructor stub
		
		Container c = getContentPane();
		c.setLayout(null);//绝对布局，自己设定位置
		
		

	
		 top_p=new JPanel();
		 top_p.setBounds(0,0,1482,90);
		 top_p.setLayout(null);
		 top_p.setBackground(Color.WHITE);
		 c.add(top_p);
		 //首页logo图片
		 ImageIcon logo=new ImageIcon("imges/logo.png");
		 
		 logopic=new JLabel(logo);
		 logopic.setBounds(60,0,logo.getIconWidth(),logo.getIconHeight());
		 top_p.add(logopic);
		 
		 //首页城市选择
		 city=new JLabel("湘潭") ;
		 city.setBounds(250, 10, 70, 40);
		 
		 city.setFont(new Font("楷体", Font.CENTER_BASELINE, 30));
		 top_p.add(city);
		 
		 
		 //首页按钮
		 homepage=new JLabel("首页");
		 homepage.setBounds(360, 10, 70, 40);
		 homepage.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 top_p.add(homepage);
		 
		 //回到影视页面按钮
		 film=new JLabel("影片");
		 film.setBounds(480, 10, 70, 40);
		 film.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 top_p.add(film);
		 //回到影院的按钮
		 cinema=new JLabel("影院");
		 cinema.setBounds(590, 10, 70, 40);
		 cinema.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 top_p.add(cinema);
		 //个人中心
		 
		 personData=new JLabel("个人中心 |");
		 personData.setBounds(1230, 10, 120, 40);
		 personData.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 top_p.add(personData);
		 
		 //退出
		 out=new JLabel("退出");
		 out.setBounds(1350, 10, 70, 40);
		 out.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 top_p.add(out);
		 
		 
		 center_p=new JPanel();
		 center_p.setLayout(null);
		 center_p.setBounds(0,90,1482,900);
		 c.add(center_p);
		 
		 center_p_top=new JPanel();
		 center_p_top.setLayout(null);
		 center_p_top.setBounds(0,0,1482,30);
		 center_p_top.setBackground(Color.WHITE);
		 center_p.add(center_p_top);
		 
		 nowFilm =new JLabel("正在热映（）");
		 nowFilm.setBounds(80, 0, 100, 30);
		 nowFilm.setForeground(Color.RED);
		 nowFilm.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 center_p_top.add(nowFilm);
		 
		 
		 futureFilm=new JLabel("即将上映（）");
		 futureFilm.setBounds(200, 0, 100, 30);
		 futureFilm.setEnabled(false);
		 futureFilm.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 center_p_top.add(futureFilm);
		 
		 center_p_center=new JScrollPane();
		 center_p_center.setBounds(0, 32, 1482,center_p.getHeight());
		 center_p_center.setLayout(null);
		 center_p_center.setBackground(Color.WHITE);
		 center_p.add(center_p_center);
		 
		 ImageIcon homepic1=new ImageIcon("imges/homepic1.png");
		 homep1=new JLabel(homepic1);
		 homep1.setBounds(240, 50, homepic1.getIconWidth(), homepic1.getIconHeight());
		 center_p_center.add(homep1);
		 
		 ImageIcon homepic2=new ImageIcon("imges/hoempic2.png");
		 homep2=new JLabel(homepic2);
		 homep2.setBounds(450, 50, homepic2.getIconWidth(),  homepic1.getIconHeight());
		center_p_center.add(homep2);
		 
		 ImageIcon homepic3=new ImageIcon("imges/homepic3.png");
		 homep3=new JLabel(homepic3);
		 homep3.setBounds(660, 50, homepic3.getIconWidth(),  homepic1.getIconHeight());
		center_p_center.add(homep3);
		 
		 ImageIcon homepic4=new ImageIcon("imges/homepic4.png");
		 homep4=new JLabel(homepic4);
		 homep4.setBounds(870, 50, homepic4.getIconWidth(),  homepic1.getIconHeight());
		center_p_center.add(homep4);
		 
		 ImageIcon homepic5=new ImageIcon("imges/homepic5.png");
		 homep5=new JLabel(homepic5);
		 homep5.setBounds(1080, 50, homepic5.getIconWidth(),  homepic1.getIconHeight());
		center_p_center.add(homep5);
		 
		 
		 //选座按钮
		 homeB1=new JButton("选座购票");
		 homeB1.setForeground(Color.WHITE);
		 homeB1.setBackground(Color.RED);
		 homeB1.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 homeB1.setBounds(240, 273, homepic1.getIconWidth(), 40);
		center_p_center.add(homeB1);
		 
		 homeB2=new JButton("选座购票");
		 homeB2.setForeground(Color.WHITE);
		 homeB2.setBackground(Color.RED);
		 homeB2.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 homeB2.setBounds(450, 273, homepic2.getIconWidth(), 40);
		center_p_center.add(homeB2);
		 
		 homeB3=new JButton("选座购票");
		 homeB3.setForeground(Color.WHITE);
		 homeB3.setBackground(Color.RED);
		 homeB3.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 homeB3.setBounds(660, 273, homepic3.getIconWidth(), 40);
		center_p_center.add(homeB3);
		 
		 homeB4=new JButton("选座购票");
		 homeB4.setForeground(Color.WHITE);
		 homeB4.setBackground(Color.RED);
		 homeB4.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 homeB4.setBounds(870, 273, homepic4.getIconWidth(), 40);
		center_p_center.add(homeB4);
		 
		 homeB5=new JButton("选座购票");
		 homeB5.setForeground(Color.WHITE);
		 homeB5.setBackground(Color.RED);
		 homeB5.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
		 homeB5.setBounds(1080, 273, homepic5.getIconWidth(),40);
		center_p_center.add(homeB5);
		 
		 
		 //中间图片
		 ImageIcon homepic6=new ImageIcon("imges/homepic6.png");
		 centerpic=new JLabel(homepic6);
		 centerpic.setBounds(0, 330, 1482, homepic6.getIconHeight());
		 center_p_center.add(centerpic);//增加到滚动面板
		 
		 
		 center_p_center_bottoml =new JPanel();
		 center_p_center_bottoml.setLayout(null);
		 center_p_center_bottoml.setBounds(240, 460, 310, 350);
		 center_p_center_bottoml.setBackground(Color.WHITE);
		center_p_center.add(center_p_center_bottoml);
		 
		 
		 filmRankingList=new JLabel("上周票房排行");
		 filmRankingList.setBounds(30, 0, 200, 30);
		 filmRankingList.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 center_p_center_bottoml.add(filmRankingList);
		 
		 
		 allFilm=new JLabel("全部影片>");
		 allFilm.setBounds(240, 0, 110, 30);
		 allFilm.setFont(new Font("微软雅黑", Font.ITALIC, 15));
		 allFilm.setForeground(Color.red);
		 center_p_center_bottoml.add(allFilm);
		 
		 ImageIcon homepic7=new ImageIcon("imges/homepic7.png");
		 oneFilm =new JLabel(homepic7);
		 oneFilm.setBounds(0, 35, homepic7.getIconWidth(), homepic7.getIconHeight());
		 center_p_center_bottoml.add(oneFilm);

		 
		 ImageIcon homepic8=new ImageIcon("imges/homepic8.png");
		 twoFilm =new JLabel(homepic8);
		 twoFilm.setBounds(0, 100, homepic8.getIconWidth(), homepic8.getIconHeight());
		 center_p_center_bottoml.add(twoFilm);
		 
		 ImageIcon homepic9=new ImageIcon("imges/homepic9.png");
		 threeFilm =new JLabel(homepic9);
		 threeFilm.setBounds(0, 165, homepic9.getIconWidth(), homepic9.getIconHeight());
		 center_p_center_bottoml.add(threeFilm);
		 
		 ImageIcon homepic10=new ImageIcon("imges/homepic10.png");
		 fourFilm =new JLabel(homepic10);
		 fourFilm.setBounds(0, 230, homepic10.getIconWidth(), homepic10.getIconHeight());
		 center_p_center_bottoml.add(fourFilm);
		 
		 ImageIcon homepic11=new ImageIcon("imges/homepic11.png");
		 fiveFilm =new JLabel(homepic11);
		 fiveFilm.setBounds(0, 295, homepic11.getIconWidth(), homepic11.getIconHeight());
		 center_p_center_bottoml.add(fiveFilm);
		 
		 //滚动面板中间部分
		 center_p_center_bottomc =new JPanel();
		 center_p_center_bottomc.setLayout(null);
		 center_p_center_bottomc.setBounds(580, 460, 310, 350);
		 center_p_center_bottomc.setBackground(Color.WHITE);
		center_p_center.add(center_p_center_bottomc);
		 
		 
		 cinemaRanking=new JLabel("上周票房排行");
		 cinemaRanking.setBounds(30, 0, 200, 30);
		 cinemaRanking.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		 center_p_center_bottomc.add(cinemaRanking);
		 
		 
		 allCinema=new JLabel("全部影院>");
		 allCinema.setBounds(240, 0, 110, 30);
		 allCinema.setFont(new Font("微软雅黑", Font.ITALIC, 15));
		 allCinema.setForeground(Color.red);
		 center_p_center_bottomc.add(allCinema);
		 
		 ImageIcon homepic12=new ImageIcon("imges/homepic12.png");
		 oneCinema=new JLabel(homepic12);
		 oneCinema.setBounds(0, 35, homepic12.getIconWidth(), homepic12.getIconHeight());
		 center_p_center_bottomc.add(oneCinema);
	
		 
		 ImageIcon homepic13=new ImageIcon("imges/homepic13.png");
		 twoCinema =new JLabel(homepic13);
		 twoCinema.setBounds(0, 100, homepic13.getIconWidth(), homepic13.getIconHeight());
		 center_p_center_bottomc.add(twoCinema);
		 
		 ImageIcon homepic14=new ImageIcon("imges/homepic14.png");
		 threeCinema =new JLabel(homepic14);
		 threeCinema.setBounds(0, 165, homepic14.getIconWidth(), homepic14.getIconHeight());
		 center_p_center_bottomc.add(threeCinema);
		 
		 ImageIcon homepic15=new ImageIcon("imges/homepic15.png");
		 fourCinema =new JLabel(homepic15);
		 fourCinema.setBounds(0, 230, homepic15.getIconWidth(), homepic15.getIconHeight());
		 center_p_center_bottomc.add(fourCinema);
		 
		 ImageIcon homepic16=new ImageIcon("imges/homepic16.png");
		 fiveCinema =new JLabel(homepic16);
		 fiveCinema.setBounds(0, 295, homepic16.getIconWidth(), homepic16.getIconHeight());
		 center_p_center_bottomc.add(fiveCinema);
		 
		 
		 
		 //滚动面板右边
		 center_p_center_bottomr =new JPanel();
		 center_p_center_bottomr.setLayout(null);
		 center_p_center_bottomr.setBounds(920, 460, 310, 420);
		 center_p_center_bottomr.setBackground(Color.WHITE);
		 center_p_center.add(center_p_center_bottomr);
		 
		 ImageIcon homepic17=new ImageIcon("imges/music.png");
		 musicPic=new JLabel(homepic17);
		 musicPic.setBounds(15, 0,310, 360);
		 center_p_center_bottomr.add(musicPic);
		 
		 
		 
		 newFilm=new JLabel();
		 newFilm.setBounds(0, 840, 500, 500);
		 newFilm.setLayout(null);
		center_p_center.add(newFilm);
		 
		 ImageIcon yu=new ImageIcon("imges/homepic17");
		 test=new JLabel(yu);
		 test.setBounds(0, 0, yu.getIconWidth(), yu.getIconHeight());
		 newFilm.add(test);
		 
		 
		 
		 
		 
		 
		 
		 
		 
		nowFilm.addMouseListener(this);
		futureFilm.addMouseListener(this);
	
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);//点击关闭按钮退出
		setSize(1500, 1000);//尺寸
		setLocationRelativeTo(null);//居中
		 setVisible(true);//可见		
	 }

	public static void main(String[] args) {
		new HomepageJframe();
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		Object obj=e.getSource();
		if(obj==futureFilm){
			futureFilm.setEnabled(true);
			futureFilm.setForeground(Color.RED);
			nowFilm.setEnabled(false);
			ImageIcon futureFilm1=new ImageIcon("imges/futureFilm1.png");
			homep1.setIcon(futureFilm1);
			ImageIcon futureFilm2=new ImageIcon("imges/futureFilm2.png");
			homep2.setIcon(futureFilm2);
			ImageIcon futureFilm3=new ImageIcon("imges/futureFilm3.png");
			homep3.setIcon(futureFilm3);
			ImageIcon futureFilm4=new ImageIcon("imges/futureFilm4.png");
			homep4.setIcon(futureFilm4);
			ImageIcon futureFilm5=new ImageIcon("imges/futureFilm5.png");
			homep5.setIcon(futureFilm5);
			
			homeB1.setText("2019-12-31");
			 homeB1.setForeground(Color.GRAY);
			 homeB1.setBackground(Color.WHITE);
			 homeB1.setFont(new Font("微软雅黑", Font.CENTER_BASELINE, 10));
			 
			 homeB2.setText("2020-1-1");
			 homeB2.setForeground(Color.GRAY);
			 homeB2.setBackground(Color.WHITE);
			 homeB2.setFont(new Font("微软雅黑", Font.CENTER_BASELINE, 10));
			 
			 homeB3.setText("大年初一");
			 homeB3.setForeground(Color.GRAY);
			 homeB3.setBackground(Color.WHITE);
			 homeB3.setFont(new Font("微软雅黑", Font.CENTER_BASELINE, 10));
			 
			 homeB4.setText("大年初一");
			 homeB4.setForeground(Color.GRAY);
			 homeB4.setBackground(Color.WHITE);
			 homeB4.setFont(new Font("微软雅黑", Font.CENTER_BASELINE, 10));
			 
			 homeB5.setText("大年初一");
			 homeB5.setForeground(Color.GRAY);
			 homeB5.setBackground(Color.WHITE);
			 homeB5.setFont(new Font("微软雅黑", Font.CENTER_BASELINE, 10));
			 
			 
			 
			
		}
		if(obj==nowFilm){
			nowFilm.setEnabled(true);
			nowFilm.setForeground(Color.RED);
			futureFilm.setEnabled(false);
			
			ImageIcon futureFilm1=new ImageIcon("imges/homepic1.png");
			homep1.setIcon(futureFilm1);;
			ImageIcon futureFilm2=new ImageIcon("imges/hoempic2.png");
			homep2.setIcon(futureFilm2);;
			ImageIcon futureFilm3=new ImageIcon("imges/homepic3.png");
			homep3.setIcon(futureFilm3);;
			ImageIcon futureFilm4=new ImageIcon("imges/homepic4.png");
			homep4.setIcon(futureFilm4);;
			ImageIcon futureFilm5=new ImageIcon("imges/homepic5.png");
			homep5.setIcon(futureFilm5);
			
			
			homeB1.setText("选座购票");
			homeB1.setForeground(Color.WHITE);
			homeB1.setBackground(Color.RED);
			homeB1.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
			
			
			homeB2.setText("选座购票");
			homeB2.setForeground(Color.WHITE);
			homeB2.setBackground(Color.RED);
			homeB2.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
			
			
			homeB3.setText("选座购票");
			homeB3.setForeground(Color.WHITE);
			homeB3.setBackground(Color.RED);
			homeB3.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
			
			
			homeB4.setText("选座购票");
			homeB4.setForeground(Color.WHITE);
			homeB4.setBackground(Color.RED);
			homeB4.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
			
			
			homeB5.setText("选座购票");
			homeB5.setForeground(Color.WHITE);
			homeB5.setBackground(Color.RED);
			homeB5.setFont(new Font("楷体", Font.CENTER_BASELINE, 15));
			
			
			
		}
		
	}
	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
